package com.xaicode.learn.java.multithreadarch.ch1;

/**
 * @author Locker cjxia@isoftstone.com
 * @version 1.0
 */
public class TicketWindowRunnable implements Runnable {

    private int index = 1;
    private final static int MAX = 50;

    @Override
    public void run() {
        while (index <= MAX) {
            System.out.println(Thread.currentThread() + " number is " + (index++));
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        final TicketWindowRunnable task = new TicketWindowRunnable();

        final Thread t1 = new Thread(task, "1");
        final Thread t2 = new Thread(task, "2");
        final Thread t3 = new Thread(task, "3");
        final Thread t4 = new Thread(task, "4");
        t1.start();
        t2.start();
        t3.start();
        t4.start();
    }
}
